<script setup>
import { onMounted, ref } from "vue";
import { allRankings } from '../../../api/ranking'

const artistToplist = ref({})
const rankingList = ref([])
const official = ref([]) // 官方

const getAllRankings = async () => {
  const res = await allRankings()
  artistToplist.value = res.artistToplist
  rankingList.value = res.list
  official.value = res.list.filter(item => item.ToplistType)
  console.log(official.value)
}

onMounted(() => {
  getAllRankings()
})
</script>

<template>
  <div class="rank-container">
    <div class="r-t">官方榜</div>
    <div class="rank-box">
      <div v-for="item in official" :key="item.id" class="rank-item">
        <div class="rank-item-top">
          <span>{{ item.name }}</span>
          <span>{{ item.updateFrequency }}</span>
        </div>
        <div class="rank-item-main">
          <img class="rank-item-image" :src="item.coverImgUrl" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.rank-container {
  box-sizing: border-box;
  padding: 0 24px;
}
.r-t {
  width: 100%;
  font-size: 20px;
  font-weight: bold;
  color: #000;
  text-align: left;
  letter-spacing: 2px;
}
.rank-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.rank-item {
  width: 49%;
  min-height: 120px;
  background: #fff;
  border-radius: 8px;
  box-sizing: border-box;
  padding: 0 24px;
  margin-top: 12px;
}
.rank-item-top {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #dbdbdb;
  span {
    flex: 1;
    color: #000;
    font-size: 14px;
    text-align: left;
    letter-spacing: 1px;
    &:last-child {
      color: #515c67;
      display: flex;
      justify-content: flex-end;
    }
  }
}

.rank-item-main {
  min-height: 80px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 14px 0;
}
.rank-item-image {
  width: 70px;
  height: 70px;
  border-radius: 8px;
}
</style>
